ea00c75e39631b8a849fed2f25cb603072f715a3,opennms-services/src/test/java/org/opennms/netmgt/collectd/JUnitCollectorExecutionListener.java,JUnitCollectorExecutionListener,beforeTestMethod,#TestContext#,37
Before Change
// FIXME: Is there a better way to inject the TestContext into the test class? Seems that spring doesn't give direct access...
Method m = ReflectionUtils.findMethod(testContext.getTestClass(), "setTestContext", new Class[]{TestContext.class});
if (m != null && testContext.getTestInstance() != null) {
System.err.println("invoking setTestContext on " + testContext.getTestInstance());
m.invoke(testContext.getTestInstance(), testContext);
}
After Change
// FIXME: Is there a better way to inject the instance into the test class?
if (testContext.getTestInstance() instanceof TestContextAware) {
System.err.println("injecting TestContext into TestContextAware test: "
+ testContext.getTestInstance().getClass().getSimpleName() + "."
+ testContext.getTestMethod().getName());
((TestContextAware) testContext.getTestInstance()).setTestContext(testContext);
}